Use case: HAL GPIO initialization ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
GPIO_Init_TypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = GPIO_PIN_5;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOx, &GPIO_InitStructure);
|
hal_gpio_config_t GPIO_ConfigStructure;
GPIO_ConfigStructure.mode = HAL_GPIO_MODE_OUTPUT;
GPIO_ConfigStructure.output_type = HAL_GPIO_OUTPUT_PUSHPULL;
GPIO_ConfigStructure.pull = HAL_GPIO_PULL_NO;
HAL_GPIO_Init(HAL_GPIOx, HAL_GPIO_PIN_5, &GPIO_ConfigStructure);
|
Key changes ¶
HAL2 passes the pin as a separate argument (not only via a struct field).
HAL2 separates output configuration (mode vs output type) explicitly.
Naming and enum values differ between HAL1 and HAL2 for pull/mode/output type.

